calculate profit and loss of given amount in c